import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
    state: {
        num: 6,
        list: [4, 5, 6]
    },
    mutations: {
        num_add(state) {
            if (state.num < 30) {
                state.num ++
            }
        },
        add_list(state, n){
            state.list.push(n)
        }
    },
    getters: {
        change(state){
            return 100-state.num
        },
        res(state){
            let a =0
            for (let i of state.list){
                a += i
            }
            return a
        }
    }
})
